package com.yiqingjing.nextset;

import java.util.ArrayList;

import android.app.Service;
import android.content.Context;
import android.content.Loader;
import android.location.Location;
import android.location.LocationManager;

public class GetLocation {
	private static LocationManager locationManager;
	private static Location location;
	private static ArrayList<Double> result = new ArrayList<Double>();
	
	public static ArrayList<Double> getCurrentLocation(Context context){
		locationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
		if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
			location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
			System.out.println(location.getLatitude() + " " + location.getLongitude());
		}else{
			location = locationManager.getLastKnownLocation(locationManager.NETWORK_PROVIDER);
			System.out.println(location.getLatitude() + " " + location.getLongitude());
		}
		result.add(location.getLatitude());
		result.add(location.getLongitude());
		return result;
	}
	
}
